<?php
class Zend_View_Helper_ProfileLink extends Zend_View_Helper_Abstract {
	
	public function profileLink() {
		
		$helperUrl = new Zend_View_Helper_Url();
		$auth = Zend_Auth::getInstance();
		
		if ($auth->hasIdentity()) {
			$username = $auth->getIdentity()->firstname . ' ' . strtoupper(substr($auth->getIdentity()->lastname, 0, 1)) . '.';
			$logoutLink = $helperUrl->url(array('action' => 'logout', 'controller' => 'Auth'));
			return 'Salut ' . $username . ' (<a href="' . $logoutLink . '">Déconnexion</a>)';
		}
		$loginLink = $helperUrl->url(array('action' => 'login', 'controller' => 'Auth' ) );
		return '<a href="' . $loginLink . '">Connexion</a>';
	}
}